import Loadable from 'react-loadable'
 
const LoadableComponent = component => {
  return Loadable({
    loader: component,
    loading: () => (<h1>组件懒加载中...</h1>),
  })
};

const Home = LoadableComponent(() => import(/* webpackChunkName: "home" */ '../page/home'))
const Detail = LoadableComponent(() => import(/* webpackChunkName: "detail" */ '../page/detail'))
const Search = LoadableComponent(() => import(/* webpackChunkName: "search" */ '../page/search'))
const Index = LoadableComponent(() => import(/* webpackChunkName: "index" */ '../page/home/index/index'))
const Classify = LoadableComponent(() => import(/* webpackChunkName: "clsssify" */ '../page/home/clsssify'))

const routes = [{
  component: Home,
  path: '/home',
  children: [{
    component: Index,
    path: '/home/index'
  },{
    component: Classify,
    path: '/home/classify'
  }]
}, {
  component: Detail,
  path: '/detail'
}, {
  component: Search,
  path: '/search'
}, {
  from: '/',
  to: '/home/index'
}]

export default routes